/*
 * @Description: Description
 * @Author: laoyuan
 * @Date: 2023-04-04 15:05:36
 */
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import menus from './modules/menus';
const Test = () => import('@/views/Test/index.vue');
import AppLayout from '@/layout/AppLayout.vue';
import videos from '@/router/modules/video';

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: AppLayout,
    children: [
      {
        path: '/',
        name: 'index',
        meta: { title: '首页' },
        component: () => import('@/views/Index/index.vue'),
      },
      {
        path: '/login',
        name: 'login',
        meta: { title: '登录' },
        component: () => import('@/views/Login/index.vue'),
      },
      {
        path: '/404',
        name: 'not-found',
        meta: { title: '404' },
        component: () => import('@/views/NotFound/index.vue'),
      },
      ...menus,
      ...videos,
    ],
  },
  {
    path: '/htmlPage/:id/:name',
    name: 'htmlPage',
    component: () => import('@/views/HtmlPage/index.vue'),
  },
  {
    path: '/test',
    name: 'test',
    meta: { title: '测试' },
    component: Test,
  },
  {
    path: '/:catchAll(.*)', // 捕获所有路径
    redirect: '/404',
  },
];

/** 创建路由实例 */
const router = createRouter({
  history: createWebHistory(),
  routes: routes,
});

export default router;
